app.controller('ctrlHMovie', function($scope, $interval) {
	$(".header li").removeClass("selected").eq(2).addClass("selected");
	$(window).on("touchstart", function(e) {
		e.preventDefault;
	});
	
	function addDom(){
		// 浏览器总高度
		var wH = $(document).height();
		// 可视区域的高度
		var vH = $(window).height();
		// 滚动条到顶部的垂直高度
		var sH = $(document).scrollTop();

		if (wH - vH <= sH + 2) {
			if ($(".luboW").css("display") == "block") {
				setTimeout(function() {
					$(".luboW").css("display", "none");
					$(".conC1").css({
						display: "block",
						//					marginBottom: 20 + "rem",
					});
					$(".conC1 .conUl").css({
						//					marginBottom: 20 + "rem",
					});
					$(".conC0").css("display", "none");
					$(".more").css({
						display: "block",
						marginTop: 12 + "rem",
					});
					$(document).scrollTop(10);
				}, 1000)
			} else {
				var loadingImgs = ["../img/homeMovie/1.png", "../img/homeMovie/2.png"];
//				记录图片加载完成的数量
				var loadingNum = 0;
				for (var i = 0; i < loadingImgs.length; i++) {
					var img = new Image();
					img.src = loadingImgs[i];
					img.onload = function() {
						loadingNum++;
						// 判断加载完成
						if (loadingNum == loadingImgs.length) {
							$(".conUl1").append('<li><img src="../img/homeMovie/1.png" alt="" /><p class="conFirP"><span>9.1</span></p><p class="conSecP">侏罗纪世界</p><p class="conThrP">高智商混血恐龙来袭</p></li>')
							$(".conUl1").append('<li><img src="../img/homeMovie/2.png" alt="" /><p class="conFirP"><span>9.1</span></p><p class="conSecP">末日崩塌</p><p class="conThrP">史无前例超级地震</p></li>')
						}
					}
				}
			}
		}
		if (sH <= 2) {
			if ($(".luboW").css("display") == "none") {
				setTimeout(function() {
					$(".luboW").css("display", "block");
					$(".conC1").css("display", "none");
					$(".conC0").css("display", "block");
					$(".more").css({
						display: "none",
					});
					$(document).scrollTop(0);
				}, 1000)
			}
		}
	}
	
	
	$(window).scroll(function(){
		addDom();
	});
	
	$scope.$on('$destroy',function(){
		addDom=function(){};
	});
})